Skip to content

[FIX] Weighted mean computation in Orange.statistics.util.stats#6204

Merged
markotoplak merged 2 commits intobiolab:masterfrom
markotoplak:stats-fix-weighted-mean
Nov 18, 2022
Merged

[FIX] Weighted mean computation in Orange.statistics.util.stats#6204
markotoplak merged 2 commits intobiolab:masterfrom
markotoplak:stats-fix-weighted-mean

Conversation

@markotoplak
Copy link
Copy Markdown
Member

Issue

The tests added in the first commit of this PR fail. The new tests test a combination of unit (ones) weights and NaNs, which should give exactly the same results as unweighted samples. Well, they do not, because we have been sloppy: the current code also divided with non-used weights (corresponding to NaN data entries).

Description of changes

The nanmean function was easy to extend with weights. For sparse I just needed to add a parameter. For dense I did an extension. Now, stats uses nanmean internally.

Includes
  • Code changes
  • Tests
  • Documentation

@markotoplak
Copy link
Copy Markdown
Member Author

The bug originates from 8a76580 by @nikicc. I nominate @pavlin-policar, who worked on similar code, to review this PR. :)

@markotoplak markotoplak added the dask Related (discovered in or needed) to the Dask adaptation label Nov 16, 2022
@codecov
Copy link
Copy Markdown

codecov bot commented Nov 16, 2022

Codecov Report

Merging #6204 (e01b122) into master (af9cc5f) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head e01b122 differs from pull request most recent head 9c69c4d. Consider uploading reports for the commit 9c69c4d to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6204   +/-   ##
=======================================
  Coverage   86.65%   86.65%           
=======================================
  Files         316      316           
  Lines       67991    67997    +6     
=======================================
+ Hits        58918    58924    +6     
  Misses       9073     9073           

@pavlin-policar
Copy link
Copy Markdown
Collaborator

This looks good to me. I've re-run the failing tests, but, in case they don't pass, can I just ignore them? The failures have nothing to do with this code here, and this looks ready to merge.

@markotoplak markotoplak merged commit af8124a into biolab:master Nov 18, 2022
@markotoplak markotoplak deleted the stats-fix-weighted-mean branch November 21, 2022 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dask Related (discovered in or needed) to the Dask adaptation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants